package com.snail.starter.mq.enums;

import lombok.Getter;

import java.util.Arrays;

/**
 * @author: snail framework
 * @Date: 2023/7/4 11:32
 * @Version: 1.0.0
 */
@Getter
public enum LocalMessageTypeEnum {

    KAFKA(1, "kafka"),
    DEFAULT(-1, "default"),
    ;

    private final Integer type;

    private final String desc;

    LocalMessageTypeEnum(Integer type, String desc) {
        this.type = type;
        this.desc = desc;
    }

    public static LocalMessageTypeEnum getEnumByType(Integer type){
        if (null == type) {
            return DEFAULT;
        }
        return Arrays.stream(values()).filter(localMessageTypeEnum -> localMessageTypeEnum.getType().equals(type)).findFirst().orElse(DEFAULT);
    }

}